<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>报表页面</title>
    <link href="/static/css/bootstrap.css" rel="stylesheet">
    <script type="text/javascript" src="/static/js/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="/static/js/echarts.js"></script>
</head>
<body>

<br>
<div>
    <a href="list">返回列表页面</a>
</div>
<br>

<!-- 为 ECharts 准备一个定义了宽高的 DOM -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    var nums = [];
    var names = [];

    // 指定图表的配置项和数据
    var option = {
        title: {
            text: '类型统计场地数量表'
        },
        tooltip: {},
        legend: {
            data: ['数量']
        },
        xAxis: {
            data: names
        },
        yAxis: {},
        series: [
            {
                name: '数量',
                type: 'bar',
                data: nums
            }
        ]
    };

    $.post(
        "getCallTj",
        function (list){
            for (var i in list) {
                nums.push(list[i].num);
                names.push(list[i].yname);
            }
            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
        }
    );

</script>


</body>
</html>
